package com.mmdccj.yugu.common;

import lombok.Data;

/**
 * @Author: star_
 * @date: 2023-11-25 17:28
 * <p>
 * 信息类
 */
@Data
public class Result<T> {
    // 状态码
    private int code;
    // 信息
    private String msg;
    // 数据
    private T data;

    // 成功
    public static <T> Result<T> success(String msg, T data) {
        Result<T> result = new Result<>();
        result.code = 1;
        result.msg = msg;
        result.data = data;
        return result;
    }

    // 成功
    public static <T> Result<T> success(String msg) {
        Result<T> result = new Result<>();
        result.code = 1;
        result.msg = msg;
        return result;
    }

    // 失败
    public static <T> Result<T> error(String msg) {
        Result<T> result = new Result<>();
        result.code = 0;
        result.msg = msg;
        return result;
    }

}
